

const input = {
    data() {
        return {
            msg:""
        }
    },
    template: `
    <div id="head">
        <h1>toDoList</h1>
        <input type="text" v-on:keydown.enter="btnClick"  placeholder="请输入要待办的事项" v-model.trim="msg" id="input">
        <button v-on:click="btnClick" id="add">新增</button>
    </div>
    `,
    methods: {
        btnClick() {
            if (this.msg) {
                this.$store.dispatch("add", this.msg);
                this.msg = "";
            } else {
                alert("输入为空")
            }
        }
    },
 
}
export default input